{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250
{\fonttbl\f0\fnil\fcharset0 Tahoma;\f1\fmodern\fcharset0 CourierNewPSMT;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww14160\viewh12200\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

\f0\b\fs34 \cf0 How To Use SudzC Code
\b0\fs24 \
\
The first thing to do is to make sure you copy the code into your project.  Read the README.rtf file that also tells you how to set up your project to include the libxml libraries.  Make sure you can build the solution and then you are ready to make your first call.\
\
To do that... you first create an instance of your service class.  This should be the one named after the class you used to make your web services.  For instance, if you are dealing with Widgets, you make have WidgetService... this will translate into an Objective-C class.  To use it, you alloc/init is...\
\

\f1 WidgetService* service = [[WidgetService alloc] init];
\f0 \
\
Now that class has a whole bunch of methods associated with it.  Service classes can also be set to use custom URLs, send SOAP headers, etc... but for now, we will keep it simple!  So let's say you have a method to find widgets called "Find".  You would call that method like this...\
\

\f1 [service Find: self action: @selector(handleFind:) criteria: @"test" maxRecords: 5];
\f0 \
\
In this case, we call the method with two parameters: criteria and maxRecords.  The first parameter right after Find: references the "delegate", or the object that is going to handle the request.  The second parameter "action" specifies a method that is going to handle the result.  This is the easiest way to implement a call, although there is a way to do it without the "action" method, but I'm not going to confuse you yet ;)\
\
To handle the results from the web service, you write a method called "handleFind:"  This is a method written in the delegate object you specified in the first parameter.  So in this case, make the method in the same object making the call, or "self".\
\

\f1 -(void)handleFind: (id) result \{\
	if([result isKindOfClass: [NSError class]]) \{\
		// If an error has occurred, handle it\
		return;\
	\}\
\
	if([result isKindOfClass: [SoapFault class]]) \{ \
		// If a server error has occurred, handle it\
		return;\
	\}\
\
	// Actually do something with the result...\
	self.myDataArray = (NSMutableArray*)result;\
\}\

\f0 \
So in this example, the "handleFind" method handles any response that calling the Find method creates.  Each request can return either an error (like could not resolve the domain name for instance), a SoapFault (an error occurred in your code on the server), or the actual result.  The results come back as a "typed" class, but are sent using the Objective-C "id" type, which you can kind of think of as a "var" in Javascript.\
\
Another way to handle the response, is to have the class from which you are calling the method implement the SoapDelegate protocol.  You do this in your implementation file.  So if you are writing a UITableViewController... You would use it like this...\
\

\f1 @interface MyTableViewController : UITableViewController <SoapDelegate> \{\
	// Your interface here...\
\}
\f0 \
\
The SoapDelegate class requires an onload: method, but optionally takes an onerror: and onfault: method.  This is similar to the other method, except your request does not include an "action" parameter...\
\

\f1 [service Find: self criteria: @"test" maxRecords: 5];
\f0 \
\
When the method returns results, it calls "onload:".  If it returns an error, it calls "onerror:", and when a SoapFault, "onfault:".  You write your method slightly different without all the class type testing because you know you are only going to get an actual result in onload...\
\

\f1 -(void)onload:(id)result \{\
	self.myDataArray = result;\
\}
\f0 \
\
Another common technique I use is to use the "onload:" method for every call I make in an object, and then determine what the result is to determine what to do.  So for instance, I might call "Find", which returns an array, and also "Create" which returns a Widget.  So I can do this...\
\

\f1 -(void)onload:(id)result \{\
	if([result isKindOfClass: [NSArray class]]) \{\
		self.myDataArray = result;\
	\}\
	if([result isKindOfClass:[Widget class]]) \{\
		[self.myDataArray addObject: result];\
	\}\
\}
\f0 \
\
I hope that gets you started!  Also, don't forget you can right-click on your service class to see the code.  SudzC uses the WSDL comments and such to document each method and what it returns.\
\
Enjoy!}